package com.company;

import javax.swing.JOptionPane;                 //Java消息提示框JOptionPane

public class ChangeMakerWindow
{
    public static void main(String[] args)
    {
        String amountString = JOptionPane.showInputDialog(
                "Enter a whole number from 1 to 99.\n" +
                        "I will find a combination of coins\n" +
                        "that equals that amount of change.");

        int amount;
        int originalAmount;
        int quarters;
        int dimes;
        int nickels;
        int pennies;

        amount = Integer.parseInt(amountString);                //integer.parseInt（)是将整型数据Integer转换为基本数据类型int
        originalAmount = amount;                                //它的作用是将数字字符串转化成原生整型数据。

        quarters = amount / 25;
        amount = amount % 25;
        dimes = amount / 10;
        amount = amount % 10;
        nickels = amount / 5;
        amount = amount % 5;
        pennies = amount;

        JOptionPane.showMessageDialog(null, originalAmount +                    //null 父窗口
                " cents in coins can be given as:\n" +
                quarters + " quarters\n" +
                dimes    + " dimes\n" +
                nickels  + " nickels and\n" +
                pennies  + " pennies");

        System.exit(0);
    }
}

